import requests
url = "https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=30&interval=daily"
res = requests.get(url)
data = res.json()
for entry in data["prices"]:
    print(entry)  # 时间戳, 价格


# import requests
# symbol = "BTCUSDT"
# interval = "1h"
# limit = 1000
# url = f"https://api.binance.com/api/v3/klines?symbol={symbol}&interval={interval}&limit={limit}"
# res = requests.get(url)
# data = res.json()
# # 解析为 DataFrame 或处理

# import requests
# token = "demo"  # 测试可用，正式需申请
# ticker = "BTC-USD"
# url = f"https://tsanghi.com/api/fin/crypto/daily?token={token}&ticker={ticker}"
# res = requests.get(url)
# data = res.json()
# print(data)